package com.piper.config;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = {"/**",""}, loadOnStartup = 1)
public class HttpClientServlet extends HttpServlet {

    private WebApplicationContext wac;

    private ConnectionManager manager;

    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        wac = ContextLoader.getCurrentWebApplicationContext();
        manager = wac.getBean(ConnectionManager.class);
        System.out.println("init servlet");
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {

        HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
        HttpServletResponse httpServletResponse = (HttpServletResponse)servletResponse;



    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("destory servlet");
    }
}
